<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>面向字节编程-cookie</title>
</head>
<body>
    <script>
        // cookie 是属于某个域名的，拿不到juejin的cookie
        // console.log(document.cookie,'===');
        // cookie 的优点是 每次传输都可以带上 ，他是一段文本，
        // 拿到某一个cookie name的值
        const cookieObj={};
        const cookier='_ga=GA1.2.208664408.1625399990; passport_csrf_token_default=3c7220e70a31889220553ef5a46b00e2; passport_csrf_token=3c7220e70a31889220553ef5a46b00e2; MONITOR_WEB_ID=cc73b83b-56b4-4add-87b4-0967e867f4e6; ttcid=28f7d87b9d244ec1bf628547f72d1c4829; _gid=GA1.2.1652156925.1630460574; tt_scid=xAmv1UxUgknsKOygnLU0wsLA8kH6GYjKJ.3.eVbr5ZRjvRLME-EC9oel6vlhx3c-71b8'
        const parseCookie = str=>
            str
                .split('; ')
                .map(value=>value.split('='))  // 数组变形
                .reduce((acc,v)=>{             // 将数组变为其他类型
                    acc[v[0]]=v[1];
                    return acc;
                },{});                      
        console.log(parseCookie(cookier));
    </script>
</body>
</html>